<div class="form">

	<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'sport-form',
			'enableAjaxValidation'=>false,
)); ?>

	<p class="note">
		Fields with <span class="required">*</span> are required.
	</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>80)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'gender'); ?>
		<?php //echo $form->textField($model,'gender',array('size'=>1,'maxlength'=>1)); ?>
		<?php echo $form->dropDownList($model, 'gender', array('M'=>'M - Hombre','F'=>'F - Mujer','A'=>'A - Ambos')); ?>
		<?php echo $form->error($model,'gender'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'type'); ?>
		<?php //echo $form->textField($model,'type'); ?>
		<?php echo $form->dropDownList($model, 'type', type::getTypes()); ?>
		<?php echo $form->error($model,'type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'state'); ?>
		<?php //echo $form->textField($model,'state'); ?>
		<?php echo $form->dropDownList($model, 'state', state::getStates()); ?>
		<?php echo $form->error($model,'state'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'imc'); ?>
		<?php //echo $form->textField($model,'imc'); ?>
		<?php
			//echo $model->imc;//echo $form->hiddenField($model,'imc',array('name'=>'imc2'));
			$auxRes = $model->imc;
			$i=0;
			$arSels = array();
			for($i=Count(Imc::getIMCs());$i>0;$i--){
				if(pow(2,$i)<=$auxRes){
					$auxRes = $auxRes - pow(2,$i);
					$arSels[] = pow(2,$i);
				}
			}
			$model->imc=$arSels;
			echo $form->checkBoxList($model,'imc',Imc::getIMCs(),array('separator'=>'','template'=>'<div>{input}{label}</div>')); 
		?>
		<?php echo $form->error($model,'imc'); ?>
	</div>

	<div class="row" style="background: #cccccc;">
		<?php echo $form->labelEx($model,'interest'); ?>
		<?php //echo $form->textField($model,'interests'); ?>
		<?php
			$auxRes2 = $model->interests;
			$i2=0;
			$arSels2 = array();
			for($i2=Count(Interest::getInterests());$i2>0;$i2--){
				if(pow(2,$i2)<=$auxRes2){
					$auxRes2 = $auxRes2 - pow(2,$i2);
					$arSels2[] = pow(2,$i2);
				}
			}
			$model->interests=$arSels2;
			echo $form->checkBoxList($model,'interests',Interest::getInterests(),array('separator'=>'','template'=>'<div>{input}</div><div>{label}</div>')); 
		?>
		<?php echo $form->error($model,'interests'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'min_age'); ?>
		<?php echo $form->textField($model,'min_age'); ?>
		<?php echo $form->error($model,'min_age'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'max_age'); ?>
		<?php echo $form->textField($model,'max_age'); ?>
		<?php echo $form->error($model,'max_age'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

	<?php $this->endWidget(); ?>

</div>
<!-- form -->
